<{:W('Bizhome/header',array($biz_item_num,$user))}>
    <div class="right_box">
		<div class="content">
			<div class="head_box">
				<h2>球馆列表</h2>
				<form id="myForm" action="__APP__/Home/Gymnasium/changeGym" method="post">
				<select name="gym_select" id="gym_select" onchange="formSubmit()">
				   <option >请选择</option>
				</select>
				</form>
			</div>
			
			<div class="info_table">
				<table>
					<tbody>
						<tr>
							<th>球馆名称</th>
							<th>球场名称</th>
							<th>功能</th>
						</tr>
					<foreach name="data" item="vo" key="k" >
						<!-- <input type="hidden" name="gymnasium_id" value="<{$vo.gymnasium_id}>" /> -->
                        <tr class="alt">
                         	<td><{$vo.gymnasium_name}><input type="hidden" class="court_gymnasium_id" value="<{$vo.court_gymnasium_id}>"></input><input type="hidden" class="court_id" value="<{$vo.court_id}>"></input></td>
                         	<td class="detail">
                         		<{$vo.court_name}>
                         	</td>
                         	<td>
                  
								<button onclick="delete_court(<{$k}>)">删除</button>
                         		
								<button onclick="get_booker(<{$k}>)">预订详情</button>
                         	</td>
                        </tr> 
                    </foreach>					              
					</tbody>
				</table>
				
			</div>	
			
			<div class="blank"></div>		
		</div>
	</div>	
 <script>
   var gym_info=<{$select}>;
   var select = document.getElementById("gym_select");
   var court_id_set=document.getElementsByClassName("court_id");
     var court_gym_set=document.getElementsByClassName("court_gymnasium_id");
   
   for (var i=0;i<gym_info.length;i++)
   {
     select.options.add(new Option(gym_info[i].gymnasium_name));
   }
   function formSubmit()
   {
     //alert(document.getElementById("gym_select").value);
	 document.getElementById("myForm").submit();
   }
   function delete_court(num)
   {
     
	 
	 
	 selected_court=court_id_set[num].value;
	 selected_gym=court_gym_set[num].value;
	 
	  layer.confirm('确定删除？', {
       btn: ['确定','取消'] //按钮
       }, function(){      
       $.post('__URL__/deleteCourt',{'court_id':selected_court,'court_gymnasium_id':selected_gym},function(resultList){ 			   
			  msg=resultList.msg;
			  if (msg!=0) {
			    layer.msg('球场已被预订，不能删除');
			  }
			  else 
			  {
			    layer.msg('删除成功');
			  }
    	     },'json');  
    }, function(){
      
    });
   }
   
   function get_booker(num)
   {
      selected_court=court_id_set[num].value;
	  layer.open({
                 type: 2,
                 title: '预订详情',
                 maxmin: true,
                 shadeClose: true, //点击遮罩关闭层
                 area : ['600px' , '420px'],
                 content: 'get_booker.html'
				 });
   }
   </script>

<div class="blank20"></div>
<{:W('Bizhome/footer')}>
